import { patrolingCruise } from '@/api'
import { useCarStore } from '@/stores/car'

/**
 * 灯光控制
 */
export const useLight = () => {
  const carStore = useCarStore()
  const toggleFloodingLight = (isOpen: boolean) => {
    const data = {
      code: carStore.currentCar,
      param1: 7,
      param2: 1,
      param3: isOpen ? 3 : 5,
      param4: 255
    }
    patrolingCruise(data)
    return data
  }

  const toggleAlarmLight = (isOpen: boolean) => {
    const data = {
      code: carStore.currentCar,
      param1: 8,
      param2: isOpen ? 1 : 0,
      param3: 255,
      param4: 255
    }
    patrolingCruise(data)
    return data
  }

  return {
    /**
     * 泛长光控制
     */
    toggleFloodingLight,
    /**
     * 警报灯控制
     */
    toggleAlarmLight
  }
}
